The present invention is generally directed to USB device redirection in a virtual desktop infrastructure (VDI) environment. USB device redirection generally refers to making a USB device that is connected to a client terminal accessible within a virtual desktop as if the USB device had been physically connected to the virtual desktop. In other words, when USB device redirection is implemented, a user can connect a USB device to his or her client terminal and the USB device will function as if it had been connected to the server.
FIGS. 1, 2A and 2B and the following description will provide a general overview of how USB device redirection is oftentimes implemented. In FIG. 1, a computing system 100 is depicted as including a number of client terminals 102a-102n (referenced generally herein as client(s) 102) in communication with a server 104 via a network 106. Server 104 can be configured to support a remote session (e.g., a remote desktop session) wherein a user at a client 102 can remotely access applications and data at the server 104 from the client 102. Such a connection may be established using any of several well-known techniques such as the Remote Desktop Protocol (RDP) and the Citrix® Independent Computing Architecture (ICA).
Client terminal 102 may represent a computer, a mobile phone (e.g., smart phone), a laptop computer, a thin client terminal, a personal digital assistant (PDA), a portable computing terminal, or a suitable terminal or device with a processor. Server 104 may represent a computer, a laptop computer, a computing terminal, a virtual machine (e.g., VMware® Virtual Machine), a desktop session (e.g., Microsoft Terminal Server), a published application (e.g., Microsoft Terminal Server) or a suitable terminal with a processor.
Client 102 may initiate a remote session with server 104 by sending a request for remote access and credentials (e.g., login name and password) to server 104. If server 104 accepts the credentials from client 102, then server 104 may establish a remote session, which allows a user at client 102 to access applications and data at server 104. During the remote session, server 104 sends display data to client 102 over network 106, which may include display data of a desktop and/or one or more applications running on server 104. The desktop may include, for example, icons corresponding to different applications that can be launched on server 104. The display data allows client 102 to locally display the desktop and/or applications running on server 104.
During the remote session, client 102 may send user commands (e.g., inputted via a mouse or keyboard at client 102) to server 104 over network 106. Server 104 may process the user commands from client 102 similar to user commands received from an input device that is local to server 104. For example, if the user commands include mouse movements, then server 104 may move a pointer on the desktop running on server 104 accordingly. When the display data of the desktop and/or application changes in response to the user commands, server 104 sends the updated display data to client 102. Client 102 locally displays the updated display data so that the user at client 102 can view changes at server 104 in response to the user commands. Together, these aspects allow the user at client 102 to locally view and input commands to the desktop and/or application that is running remotely on server 104. From the perspective of the client side, the desktop running on server 104 may represent a virtual desktop environment.
FIG. 2A is a block diagram of a local device virtualization system 200 in accordance with embodiments of the present invention. System 200 may include client 102 in communication with server 104 over network 106 as illustrated in FIG. 1. Client 102 may include a proxy 210, a stub driver 220, and a bus driver 230. Client 102 can be connected to a device 240, as shown in FIG. 2A. Server 104 may include an agent 250 and a virtual bus driver 260.
In accordance with USB device redirection techniques, while device 240 is not locally or physically connected to server 104 and is remote to server 104, device 240 appears to server 104 as if it is locally connected to server 104, as discussed further below. Thus, device 240 appears to server 104 as a virtual device 290.
By way of illustration and not limitation, device 240 may be any type of USB device including a machine-readable storage medium (e.g., flash storage device), a printer, a scanner, a camera, a facsimile machine, a phone, an audio device (e.g., a headset), a video device (e.g., a camera), a peripheral device, or other suitable device that can be connected to client 102. Device 240 may be an external device (i.e., external to client 102) or an internal device (i.e., internal to client 102).
Bus driver 230 can be configured to allow the operating system and programs of client 102 to interact with device 240. In one aspect, when device 240 is connected to client 102 (e.g., plugged into a port of client 102), bus driver 230 may detect the presence of device 240 and read information regarding device 240 (“device information”) from device 240. The device information may include features, characteristics and other information specific to device 240 such as a device descriptor (e.g., product ID, vendor ID and/or other information), a configuration descriptor, an interface descriptor, an endpoint descriptor and/or a string descriptor. Bus driver 230 may communicate with device 240 through a computer bus or other wired or wireless communications interface.
In accordance with USB device redirection techniques, device 240 may be accessed from server 104 as if the device were connected locally to server 240. Device 240 may be accessed from server 104 when client 102 is connected to server 104 through a user session running on server 104. For example, device 240 may be accessible from the desktop running on server 104 (i.e., virtual desktop environment). To enable this, bus driver 230 may be configured to load stub driver 220 as the default driver for device 240. Stub driver 220 may be configured to report the presence of device 240 to proxy 210 and to provide the device information (e.g., device descriptor) to proxy 210. Proxy 210 may be configured to report the presence of device 240, along with the device information, to agent 250 of server 104 over network 106. Thus, stub driver 220 redirects device 240 to server 104 via proxy 210.
Agent 250 may be configured to receive the report from proxy 210 that device 240 is connected to client 102 and the device information. Agent 250 may further be configured to associate with the report from proxy 210 one or more identifiers for client 102 and/or for a user session through which client 102 is connected to server 104, such as a session number or a session locally unique identifier (LUID). Agent 250 can provide notification of device 240, along with the device information, to virtual bus driver 260. Virtual bus driver 260 (which may be a TCX USB bus driver, or any other bus driver) may be configured to create and store in memory a record corresponding to device 240, the record including at least part of the device information and session identifiers received from agent 250. Virtual bus driver 260 may be configured to report to operating system 170 of server 104 that device 240 is connected and to provide the device information to the operating system. This allows the operating system of server 104 to recognize the presence of device 240 even though device 240 is connected to client 102.
The operating system of server 104 may use the device information to find and load one or more appropriate device drivers for device 240 at server 104. Each driver may have an associated device object (object(s) 281a, 281b, . . . , 281n, referred to generally as device object(s) 281), as illustratively shown in FIG. 2A. A device object 281 is a software implementation of a real device 240 or a virtualized (or conceptual) device 290. Different device objects 281 layer over each other to provide the complete functionality. The different device objects 281 are associated with different device drivers (driver(s) 282a, 282b, . . . 282n, referred to generally as device driver(s) 282). In an example, a device 240 such as a USB flash drive may have associated device objects including objects corresponding to a USB driver, a storage driver, a volume manager driver, and a file system driver for the device. The device objects 281 corresponding to a same device 240 form a layered device stack 280 for device 240. For example, for a USB device, a USB bus driver will create a device object 281a stating that a new device has been plugged in. Next, a plug-and-play (PNP) component of the operating system will search for and load the best driver for device 240, which will create another device object 281b that is layered over the previous device object 281a. The layering of device objects 281 will create device stack 280.
Device objects 281 may be stored in a memory of the server 104 associated with virtual bus driver 260. In particular, device objects 281 and resulting device stack 280 may be stored in random-access memory of server 104. Different devices 240/290 can have device stacks having different device objects and different numbers of device objects. The device stack may be ordered, such that lower level device objects (corresponding to lower level device drivers) have lower numbers than higher level device objects (corresponding to higher level device drivers). The device stack may be traversed downwards by traversing the stack from higher level objects to lower level objects. For example, in the case of an illustrative device stack 280 corresponding to a USB flash drive, the ordered device stack may be traversed downwards from a high-level file system driver device object, to a volume manager driver device object, to a storage driver device object, to a USB driver device object, and finally to a low-level virtual bus driver device object. Different device stacks 280 can be layered over each other to provide the functionality of the devices 240/290 inside devices, like USB Headsets, or USB pen drives. A USB pen drive, for example, can create a USB device stack first, over which it can create a storage device stack, where each of the device stacks have two or more device objects.
Once one or more device object(s) 281 are loaded by operating system 170 of server 104, each device object 281 can create a symbolic link (also referred to as a “device interface”) to device object 281 and associated device driver 282. The symbolic link is used by applications running on server 104 to access device object 281 and device 240/290. The symbolic link can be created by a call to a function such as IoCreateSymbolicLink( ) including such arguments as a name for the symbolic link, and a name of device object 281 or associated device 240. In one example, for example, a symbolic link to a USB flash drive device 240 is created by a call from a device object 281 for device 240 to the function IoCreateSymbolicLink( ) including arguments “\\GLOBAL??\C:” (i.e., the name for the symbolic link) and “\Device\HarddiskVolume1” (i.e., a name of the device object).
The creation of a symbolic link results in an entry being created in an object manager namespace (OMN) of operating system 170. The OMN stores information on symbolic links created for and used by operating system 170, including symbolic links for devices 240, virtualized devices 290, and applications 270 running on server 104.
As a result of the symbolic link creation process, a symbolic link to device 240 is enumerated in the OMN of server 104. Once the presence of device 240 is reported to operating system 170 of server 104, device 240 may be accessible from a user session (and associated desktop) running on server 104 (i.e., virtual desktop environment). For example, device 240 may appear as an icon on the virtual desktop environment and/or may be accessed by applications running on server 104.
An application 270 running on server 104 may access device 240 by sending a transaction request including the symbolic link for device 240 to operating system 170. Operating system 170 may consult the Object Manager Namespace to retrieve an address or other identifier for the device itself 240 or for a device object 281 associated with device 240. Using the retrieved address or identifier, operating system 170 forwards the transaction request for device 240 either directly, through a device object 281 of device stack 280, and/or through virtual bus driver 260. Virtual bus driver 260 may direct the transaction request to agent 250, which sends the transaction request to proxy 210 over network 106. Proxy 210 receives the transaction request from agent 250, and directs the received transaction request to stub driver 220. Stub driver 220 then directs the transaction request to device 240 through bus driver 230.
Bus driver 230 receives the result of the transaction request from device 240 and sends the result of the transaction request to stub driver 220. Stub driver 220 directs the result of the transaction request to proxy 210, which sends the result of the transaction request to agent 250 over network 106. Agent 250 directs the result of the transaction request to virtual bus driver 260. Virtual bus driver 260 then directs the result of the transaction request to application 270 either directly or through a device object 281 of device stack 280.
Thus, virtual bus driver 260 may receive transaction requests for device 240 from application 270 and send results of the transaction requests back to application 270 (either directly or through a device object 281 of device stack 280). As such, application 270 may interact with virtual bus driver 260 in the same way as with a bus driver for a device that is connected locally to server 104. Virtual bus driver 260 may hide the fact that it sends transaction requests to agent 250 and receives the results of the transaction requests from agent 250 instead of a device that is connected locally to server 104. As a result, device 240 connected to client 102 may appear to application 270 as if the physical device 240 is connected locally to server 104.
The Object Manager Namespace (OMN) stores information on symbolic links created for use by operating system 170, including symbolic links for devices and for applications running on server 104. The Object Manager Namespace generally includes several different namespaces for storing symbolic link information for applications and devices. For example, the Object Manager Namespace can include namespaces such as: a “Global” namespace used to store symbolic link information for devices and applications that are shared by all user sessions running on server 104; various “Local” namespaces, each associated with a user session running on server 104, used to store information for applications used by (and restricted to) the associated user session; and a “Device” namespace used to store device object names of devices and virtual devices accessible by server 104. A “Global” namespace may be referred to as a global namespace. A “Local” namespace may be referred to as a local namespace. A “Device” namespace may be referred to as a device namespace.
As described herein, symbolic links can be stored in a global namespace or a local namespace. Symbolic links stored in a global namespace may be available to the entire system (i.e., to all user sessions running on server 104), while symbolic links stored in a local namespace may only be seen and accessed by the session for which they are created. For example, “\\GLOBAL??\c:” may be a symbolic link stored in a global namespace. “\Device\HarddiskVolume1” may be a device object name stored in a device namespace. A symbolic link “\\GLOBAL??\c:” may be pointing to a device object having a device object name of “\Device\HarddiskVolume1”. Because “c:” is a symbolic link in the global namespace directory, such a symbolic link may be accessed by the entire system, including all the users logged in through their respective user sessions. A user application can open “\\GLOBAL??\c:” or just “c:” to access the actual device.
In certain operating systems, such as the Windows operating system, the creation of the symbolic link for a device 240 results in an entry being created in a Global namespace of the Object Manager Namespace. Because the symbolic link is created in the Global namespace, the symbolic link can be accessed from any user session running on server 104. As a result, the device 240 associated with the symbolic link can be accessed from any user session on server 104, and/or from any client terminal having an active user session on server 104.
FIG. 2B illustratively shows a block diagram of a computer system 100 providing local device virtualization. As previously described in relation to FIG. 1, system 100 includes client terminals 102a-102n communicating through network 106 with server 104. As described in relation to FIG. 2A above, each device 240a, 240b can be virtualized on server 104 to provide access to the device from a user session on server 104 through a corresponding virtual device 290a, 290b. For example, when device 240a is connected to client terminal 102a, drivers for device 240a may be loaded in operating system 170 of server 104, device 240a may be virtualized on server 104 as virtual device 290a, and a symbolic link to the device 240a may be created in the Object Manager Namespace of operating system 170. Once the symbolic link is created, a user of client terminal 102a may be able to access device 240a through a user session on server 104. Similarly, when device 240b is connected to client terminal 102b, a symbolic link to the device 240b may be created in the Object Manager Namespace of operating system 170 of server 104. Once the symbolic link is created, a user of client terminal 102b may be able to access device 240b through a user session on server 104.
The symbolic links to the devices 240a, 240b are created in a Global namespace of the Object Manager Namespace of operating system 170. As a result, the symbolic links and associated devices can be accessed from and used by any user session running on server 104. For example, as illustratively shown in FIG. 2B, a user of client terminal 102a having a user session on server 104 may access both device 240a as well as virtual device 240b′ from the user session. Similarly, a user of client terminal 102b having a user session on server 104 may access both device 240b as well as virtual device 240a′ from the user session. Finally, a user of client terminal 102c having a user session on server 104 may access both virtual device 240a′ and 240b′ from the user session.
Hence, the device virtualization described in relation to FIGS. 2A and 2B provides unrestricted access to devices 240 connected locally to client terminals 102 from any user session on server 104. As such, a redirected device becomes a local device to the server and can be accessed by all the users' sessions connected to that server. For example a printer or a mass storage device, when redirected by one user connected through a session on the server, will show up as a local device and all the users can read/write the mass storage device and print using the printer.
This redirection process is implemented in a similar manner even when the redirected device is a USB composite device. A USB composite device (or simply “composite device”) is a USB device that performs more than one type of function. More specifically, a composite device includes more than one device class. For example, a USB printer that also includes a scanner is a composite device since the printer functionality and the scanner functionality fall into different classes. In USB terminology, a composite device is generally referred to as providing multiple interfaces. In this sense, an individual interface of a composite device can be viewed in a similar manner as a single “non-composite” USB device.
Accordingly, when a composite device is connected to a client terminal and redirected to the server, each interface of the composite device is redirected and made available on the server. FIG. 3 illustrates an example of how this redirection of a composite device is implemented. FIG. 3 is substantially the same as FIG. 2A. However, in FIG. 3, a composite device 340 having two interfaces 340a, 340b is connected to client terminal 102. In response, and assuming redirection is enabled on client terminal 102, both interfaces 340a, 340b will be redirected to server 104. It is noted that, although a single stub driver 220 is shown, it many cases, a separate stub driver 220 would be loaded for each redirected interface.
In a similar manner as described above, a device stack 391a, 391b is created for each interface 340a, 340b respectively. It is noted that in many instances, a USB composite class driver (e.g., usbccgp.sys in the Windows implementations) can be employed as a lower level driver in each of device stacks 391a, 391b. However, even when this USB composite class driver is employed, two separate device stacks would still be created for the two interfaces of the composite device.
Device stack 391a comprises layered objects 394a-394n with corresponding drivers 395a-395n, and device stack 391b comprises layered objects 396a-396n with corresponding drivers 397a-397n. Each device stack functions in a similar manner as described above thereby causing virtual devices 390a, 390b corresponding to interfaces 340a, 340b respectively to appear as if they were locally connected to server 104. In this way, each of interfaces 340a, 340b will become accessible within any remote session established with server 104.
In some cases, it may not be desirable to redirect all interfaces of a composite device. Accordingly, various client side redirection techniques have been developed to allow less than all of the interfaces of a composite device to be redirected to the server with the non-redirected interfaces remaining local for use in a typical fashion on the client. For example, the Logitech C310 HD webcam includes three interfaces: (1) a webcam; (2) an HID interface; and (3) a microphone. If this webcam were connected to client terminal 102 while client terminal 102 has established a remote session with server 104, the client side components may be configured to redirect the webcam and HID interfaces while leaving the microphone interface local.
FIG. 4 illustrates an example of how this selective redirection of interfaces of a composite device can be implemented. FIG. 4 is substantially the same as FIG. 3 but provides some additional details to better explain how interfaces of a composite device can be selectively redirected. In FIG. 4, a composite device 440 that includes a webcam interface 440a, an HID interface 440b, and a microphone interface 440c is connected to client terminal 102. In response, bus driver 230 creates a physical device object (PDO) (not shown) for composite device 440 and generates a plug-and-pay event to report the new PDO to the operating system (not shown). The operating system will then query bus driver 230 for the hardware IDs associated with the PDO in order to identify the appropriate driver to load. In many cases when the connected device is a composite device, this process will result in a generic parent driver (Usbccgp.sys) being loaded which is represented in FIG. 4 as USB composite class driver 231.
When device redirection is enabled, proxy 210 can be configured to interface with USB composite class driver 231 (e.g., via hooking or filtering) in order to determine which interfaces composite device 440 includes. In this example, it will be assumed that proxy 210 is configured to redirect Webcam and HID interfaces but to leave microphone interfaces local. Accordingly, FIG. 4 shows that a webcam stub driver 420a and an HID stub driver 420b are loaded to implement redirection of the corresponding interfaces in the same manner as described above with respect to stub driver 220 (i.e., by causing device stacks 491a and 491b to be created on server 104 representing virtual webcam 490a and virtual HID 490b respectively). In contrast, because the microphone interface is not redirected, a microphone driver stack 491c is created only on client terminal 102 in a standard manner.
The operating system generates a separate hardware identifier for each interface of a composite device. The hardware identifier is generated from the idVendor and idProduct fields of the USB_DEVICE_DESCRIPTOR structure for the USB device. When the device includes multiple interfaces, the number of the interface is appended at the end of the hardware identifier to create the different hardware identifiers for each interface. For example, in the Logitech C310 HD webcam, the webcam interface has a hardware ID of Vid_046D&Pid_081B&MI_00, the HID interface has a hardware ID of Vid_046D&Pid_081B&MI_01, and the microphone interface has a hardware ID of Vid_046D&Pid_081B&MI_02. The “MI” in the suffix MI_xx indicates that it is an interface to a composite device and the “xx” indicates which interface number it is. Therefore, the webcam is interface 00, the HID is interface 01, and the microphone is interface 02. These hardware identifiers are employed by the operating system to load the appropriate driver(s) (i.e., to implement plug-and-play functionality).
However, when less than all of the interfaces of a composite device are redirected, proxy 210 will treat each redirected interface as a simple USB device (i.e., as if it were not an interface of a composite device). More particularly, proxy 210 will report to agent 250 that a webcam device has been connected and separately report that an HID has been connected to client terminal 102. Because the interfaces are redirected as simple devices (rather than as part of a composite device), the server side functionality will not generate a hardware identifier for the interface that includes the interface number suffix.
A general example of this is shown in FIG. 4A. When composite device 440 is connected to client terminal 102, proxy 210 can receive device information 400 pertaining to composite device 440. Device information 400 may include a device descriptor, one or more configuration descriptors (only one is shown), three interface descriptors (one for each of the webcam, HID, and microphone interfaces), and one or more endpoint descriptors for each interface. This information can be obtained in any suitable manner such as by reading the USB_DEVICE_DESCRIPTOR, USB_CONFIGURATION_DESCRIPTOR, USB_INTERFACE_DESCRIPTOR, AND USB_ENPOINT_DESCRIPTOR structures for composite device 440 or otherwise obtaining the relevant content of such descriptors from the underlying driver.
In this example, since the microphone interface will not be redirected, proxy 210 can redirect the other two interfaces as if they were simple USB devices. For example, in FIG. 4A, proxy 210 is shown as sending a device arrival notification 401 to agent 250 where the device arrival notification 401 includes a subset 400a of device information 400. Assuming device arrival notification 401 pertains to webcam interface 440a, subset 400a can include only the interface descriptor pertaining to the webcam interface with the configuration descriptor being configured to reflect that only a single interface is provided (e.g., by setting the bNumInterfaces field in the USB_CONFIGURATION_DESCRIPTOR structure to 0x01). The device descriptor in subset 400a can also include a bDeviceClass field set to the class code for the interface (as opposed to specifying this class code in the interface descriptor as would be the case in device information 400). Proxy 210 would also send a separate but similar device arrival notification pertaining to the HID interface.
As a result, during the plug-and-play functionality on server 104, operating system 170 will generate a hardware identifier of Vid_046D&Pid_081B for each redirected interface. Operating system 170 will then attempt to identify appropriate driver(s) using this hardware identifier. However, because the vendor supplied driver will be registered under the hardware identifier that includes the “MI_xx” suffix, operating system 170 will not load the appropriate vendor supplied driver. Instead, operating system 170 may load a generic driver or no driver at all. For example, FIG. 4 represents a case where operating system 170 has loaded a generic driver 495a for virtual webcam 490a and a generic driver 495b for virtual HID 490b. If a generic driver is loaded for the redirected interface, the full vendor-supplied functionality may not be available for the redirected interface. Further, if no driver is loaded, the redirected interface will not be available on server 104 (and will also not be available on client terminal 102 due to the redirection).